function AdvancedSearch()
{
	alert('Advanced Search not yet implemented');
}

function Search()
{
//	alert('Search not yet implemented');
	document.getElementById('Action').value="ShowSearch";
	document.getElementById('PageForm').submit();
}

function Home()
{
	document.getElementById('Action').value="";
	document.getElementById('PageForm').submit();
}

function Logon()
{
//	alert('Logon not yet implemented');
	document.getElementById('Action').value="logon";
	document.getElementById('PageForm').submit();
}

function Logoff()
{
//	alert('Logoff not yet implemented');
	document.getElementById('Action').value="logoff";
	document.getElementById('SessionID').value="";
	document.getElementById('User').value="";
	document.getElementById('UserID').value="";
	document.getElementById('PageForm').submit();
}

function MessageClose()
{
	document.getElementById('message').style.display="none";
//	alert('MessageClose not yet implemented');
}

function ShowCategory(category)
{
	document.getElementById('Action').value="ShowCategory";
	document.getElementById('Category').value=category;
	document.getElementById('PageForm').submit();	
}

function OnMouseOverShowCategory(element){document.getElementById(element).className= "CategoryNavigationHover";}
function OnMouseOutShowCategory(element){document.getElementById(element).className= "CategoryNavigation";}

function ShowRecentlyAdded()
{
	document.getElementById('Action').value="ShowRecentlyAdded";
	document.getElementById('PageForm').submit();	
}

function ShowMostViewed()
{
	document.getElementById('Action').value="ShowMostViewed";
	document.getElementById('PageForm').submit();	
}

//function OnMouseOverShortcutButtons(element){document.getElementById(element).className= "ShortcutButtonsHover";}
//function OnMouseOutShortcutButtons(element){document.getElementById(element).className= "ShortcutButtons";}

function OnMouseOverShortcutButtons(element){$(element).addClass("ShortcutButtonsHover");}
function OnMouseOutShortcutButtons(element){$(element).removeClass("ShortcutButtonsHover");}


function OnClickChoral()
{
//	alert ("Choral");
	document.getElementById('Action').value="ShowCategory";
	document.getElementById('Category').value="1";
	document.getElementById('PageForm').submit();
}

function OnClickOrgan()
{
//	alert ("Organ");
	document.getElementById('Action').value="ShowCategory";
	document.getElementById('Category').value="2";
	document.getElementById('PageForm').submit();
}

function OnClickLiturgy()
{
//	alert ("Liturgy");
	document.getElementById('Action').value="ShowCategory";
	document.getElementById('Category').value="3";
	document.getElementById('PageForm').submit();
}

function OnClickProfessional()
{
//	alert ("Professional");
	document.getElementById('Action').value="ShowCategory";
	document.getElementById('Category').value="4";
	document.getElementById('PageForm').submit();
}

function OnMouseOverChoral(){document.getElementById('ImgChoral').src = "Images/Choral.png";}
function OnMouseOutChoral(){document.getElementById('ImgChoral').src = "Images/ChoralA.png";}

function OnMouseOverOrgan(){document.getElementById('ImgOrgan').src = "Images/Organ.png";}
function OnMouseOutOrgan(){document.getElementById('ImgOrgan').src = "Images/OrganA.png";}

function OnMouseOverLiturgy(){document.getElementById('ImgLiturgy').src = "Images/Liturgy.png";}
function OnMouseOutLiturgy(){document.getElementById('ImgLiturgy').src = "Images/LiturgyA.png";}

function OnMouseOverProfessional(){document.getElementById('ImgProfessional').src = "Images/Professional.png";}
function OnMouseOutProfessional(){document.getElementById('ImgProfessional').src = "Images/ProfessionalA.png";}



/************************************ ShowSection Scripts ***************************/
/*
function ShowChoralCategory(category)
{
//	alert ("ShowChoralCategory("+category+") is not yet implemented");
	document.getElementById('Action').value="ShowChoralCategory";
	document.getElementById('Category').value=category;
	document.getElementById('PageForm').submit();
}

function ShowOrganCategory(category)
{
//	alert ("ShowOrganCategory("+category+") is not yet implemented");
	document.getElementById('Action').value="ShowOrganCategory";
	document.getElementById('Category').value=category;
	document.getElementById('PageForm').submit();
}

function ShowLiturgyCategory(category)
{
//	alert ("ShowLiturgyCategory("+category+") is not yet implemented");
	document.getElementById('Action').value="ShowLiturgyCategory";
	document.getElementById('Category').value=category;
	document.getElementById('PageForm').submit();
}

function ShowProfessionalCategory(category)
{
//	alert ("ShowProfessionalCategory("+category+") is not yet implemented");
	document.getElementById('Action').value="ShowProfessionalCategory";
	document.getElementById('Category').value=category;
	document.getElementById('PageForm').submit();
}

function OnMouseOverBrowse(element){document.getElementById(element).src = "Images/Browse1.png";}
function OnMouseOutBrowse(element){document.getElementById(element).src = "Images/Browse.png";}
*/
/************************************  ShowCategory Scripts *************************/

function OnMouseOverSection(element){document.getElementById(element).className= "SectionHover";}
function OnMouseOutSection(element){document.getElementById(element).className = "Section";}



function OnMouseOverSummary(element){document.getElementById(element).className= "SummaryHover";}
function OnMouseOutSummary(element){document.getElementById(element).className = "Summary";}

function OnClickSummary(ResourceID)
{
//	alert (document.getElementById('OverrideDivAction').value);
	if(document.getElementById('OverrideDivAction').value=='False')
	{
		// save action
		action = document.getElementById('Action').value;
		
		document.getElementById('Action').value="ShowResource";
		document.getElementById('ResourceID').value=ResourceID;
//		document.getElementById('PageForm').target = "_blank";
		document.getElementById('PageForm').target = "_self";
		document.getElementById('PageForm').submit();
		
/*		// put back original window
		document.getElementById('Action').value=action;
		document.getElementById('ResourceID').value='';
		document.getElementById('PageForm').target = "_self";*/
	}
	else 
		{
//		alert('Don\'t do it');
		document.getElementById('OverrideDivAction').value='False';
		}
}

function OnClickEditSummary(ResourceID)
{
//	alert("OnClickEditSummary");
	document.getElementById('Action').value="adminEditResource";
	document.getElementById('SubAction').value="EditResource";
	document.getElementById('ResourceID').value=ResourceID;
	document.getElementById('PageForm').submit();
}

function OnClickSubmitSummary(ResourceID)
{
	document.getElementById('Action').value="adminSubmitResource";
	document.getElementById('SubAction').value="SubmitResourcePreview";
	document.getElementById('ResourceID').value=ResourceID;
	document.getElementById('PageForm').submit();
}

function OnClickApproveSummary(ResourceID)
{
	document.getElementById('Action').value="adminApproveResource";
	document.getElementById('SubAction').value="ApproveResourcePreview";
	document.getElementById('ResourceID').value=ResourceID;
	document.getElementById('PageForm').submit();
}


/************************************ Summary Admin Control Scripts ***************************/
function OnMouseOverSummaryAdminEdit(element){document.getElementById(element).className= "SummaryAdminControlsHover";}
function OnMouseOutSummaryAdminEdit(element){document.getElementById(element).className = "SummaryAdminControls";}

/*
function OnClickSummaryAdminEdit(ResourceID)
{	
//	alert('Edit resource '+ResourceID);
	document.getElementById('OverrideDivAction').value='True';
}
*/

function OnMouseOverSummaryAdminRemove(element){document.getElementById(element).className= "SummaryAdminControlsHover";}
function OnMouseOutSummaryAdminRemove(element){document.getElementById(element).className = "SummaryAdminControls";}

function OnClickSummaryAdminRemove(ResourceID)
{	
	alert('Remove resource '+ResourceID);
	document.getElementById('OverrideDivAction').value='True';
}



/************************************ Admin Div Scripts ***************************/
function OnMouseOverAdmin(element){document.getElementById(element).className= "menuAdminHover";}
function OnMouseOutAdmin(element){document.getElementById(element).className = "menuAdmin";}

function OnClickAdmin(Command)
{
//	alert ('Not yet implemented');
	document.getElementById('Action').value=Command;
//	document.getElementById('ResourceID').value=ResourceID;
	document.getElementById('PageForm').submit();
}


function OnClickEditResource(ResourceID)
{
//	alert ("OnClickEditResource");
	if(document.getElementById('OverrideDivAction')!=null)
		document.getElementById('OverrideDivAction').value='True';
	document.getElementById('Action').value="adminEditResource";
	document.getElementById('SubAction').value="EditResource";
	document.getElementById('ResourceID').value=ResourceID;
	document.getElementById('PageForm').submit();
}

function OnClickRemoveResource(ResourceID)
{
	
	if(document.getElementById('OverrideDivAction')!=null)
		document.getElementById('OverrideDivAction').value='True';
	var r = confirm("Do you really want to remove this resource");
	if (r==true)
	{
		document.getElementById('Action').value="adminEditResource";
		document.getElementById('SubAction').value="RemoveResource";
		document.getElementById('ResourceID').value=ResourceID;
		document.getElementById('PageForm').submit();
	}
}


/************************************* Alphabet Search Scripts ******************************/ 

function OnMouseOverAlphabetLetter(PanelName,Character){document.getElementById(PanelName+'-'+Character).className=PanelName+'SpanHover';}
function OnMouseOutAlphabetLetter(PanelName,Character)
{
	// if this letter is the selected letter don't deselect it
	if(document.getElementById('CategorySearchLetterLetter').value != Character)
		document.getElementById(PanelName+'-'+Character).className=PanelName+'Span';
}
function OnClickAlphabetLetter(PanelName,Character)
{

//	alert (PanelName+' '+Character);
	if(document.getElementById('CategorySearchLimitStart')!=null)
		document.getElementById('CategorySearchLimitStart').value = '0';
	document.getElementById(PanelName+'Letter').value = Character;
	document.getElementById('PageForm').submit();
}

/**************************************  Display Limit Scripts ********************************/

function OnChangeCategorySearchLimit()
{
//	alert("OnChangeCategorySearchLimit();");
	document.getElementById('PageForm').submit();
}

function OnMouseOverCategorySearchLimitBack(){document.getElementById('CategorySearchLimitBack').className= "CategorySearchLimitButtonHover";}
function OnMouseOutCategorySearchLimitBack(){document.getElementById('CategorySearchLimitBack').className= "CategorySearchLimitButton";}

function OnClickCategorySearchLimitBack()
{
//	alert(document.getElementById('CategorySearchLimitStart').value);
//	alert(document.getElementById('CategorySearchLimitNumber').value);
	if(parseInt(document.getElementById('CategorySearchLimitStart').value) >= parseInt(document.getElementById('CategorySearchLimitNumber').value))
	{
//		alert ("doing the maths");
		document.getElementById('CategorySearchLimitStart').value = parseInt(document.getElementById('CategorySearchLimitStart').value) - parseInt(document.getElementById('CategorySearchLimitNumber').value);
	}
//	alert(document.getElementById('CategorySearchLimitStart').value);
	document.getElementById('CategorySearchLetterLetter').value = AlphabetLetterSelected;
	document.getElementById('PageForm').submit();
}

function OnMouseOverCategorySearchLimitForward(){document.getElementById('CategorySearchLimitForward').className= "CategorySearchLimitButtonHover";}
function OnMouseOutCategorySearchLimitForward(){document.getElementById('CategorySearchLimitForward').className= "CategorySearchLimitButton";}

function OnClickCategorySearchLimitForward()
{
//	alert(document.getElementById('CategorySearchLimitStart').value)
	document.getElementById('CategorySearchLimitStart').value=parseInt(document.getElementById('CategorySearchLimitStart').value) + parseInt(document.getElementById('CategorySearchLimitNumber').value);
	document.getElementById('CategorySearchLetterLetter').value = AlphabetLetterSelected;
	document.getElementById('PageForm').submit();
}



function AutoFillResource(type)
{
	switch(type)
	{
		case 'Composer':
			firstnameandinitials = $.trim(document.getElementById('InsertRecord_Composers_FirstName').value + ' ' + document.getElementById('InsertRecord_Composers_SecondNames').value);
			
			title = document.getElementById('InsertRecord_Composers_Surname').value + ' (' + firstnameandinitials + ')';
			document.getElementById('InsertRecord_Resources_ResourceTitle').value = title;
			
			description = 'Composer information for ' + document.getElementById('InsertRecord_Composers_FirstName').value;
			if(document.getElementById('InsertRecord_Composers_SecondNames').value!="") description += ' ' + document.getElementById('InsertRecord_Composers_SecondNames').value;
			description += ' ' + document.getElementById('InsertRecord_Composers_Surname').value;
			document.getElementById('InsertRecord_Resources_ResourceDescription').value = description;
			
			keywords =  'Composer ' + document.getElementById('InsertRecord_Composers_Surname').value;
			document.getElementById('InsertRecord_Resources_ResourceKeywords').value = keywords;
			
			break;
			
		case 'Repertoire':
			string = document.getElementById('InsertRecord_Composers_Surname').value + ' (' + document.getElementById('InsertRecord_Composers_FirstName').value + ' ' + document.getElementById('InsertRecord_Composers_SecondNames').value + ') - ' + document.getElementById('InsertRecord_RepertoireItems_Title').value;
			document.getElementById('InsertRecord_Resources_ResourceTitle').value = string;
			
			string = 'Repertoire information for ' + document.getElementById('InsertRecord_RepertoireItems_Title').value + ' by ' + document.getElementById('FirstNameVInsertRecord_Composers_FirstNamealue').value + ' ' + document.getElementById('InsertRecord_Composers_SecondNames').value + ' ' + document.getElementById('InsertRecord_Composers_Surname').value;
			document.getElementById('InsertRecord_Resources_ResourceDescription').value = string;
			
			document.getElementById('InsertRecord_Resources_ResourceKeywords').value = document.getElementById('SurnameValue').innerHTML + ' ' + document.getElementById('InsertRecord_RepertoireItems_Title').value;
		
			break;
			
		default:
			break;
	
	}
}


